﻿-- =============================================
-- Author:		<Author,Shane>
-- Create date: <Create Date,20150213>
-- Description:	<Description,获取完整的用户登录信息，用于登录和权限获取并存入缓存，包括用户名密码企业权限等>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Users_GetItem_UserName_All]
	(
		@UserName nvarchar(50)
	)
AS
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY UserId) AS Row,
		UserId,
		UserName,
		Password,
		LCM_pw,
		RTX,
		Email,
		CompanyId,
		ISNULL([DepartmentId],0) AS[DepartmentId], --- 部门ID
		[Name],
		CreateDate,
		IsLockout,
		ISNULL(LastLoginDate,'1900-01-01') As LastLoginDate,
		FailedPasswordAttemptCount,
		ISNULL([UserInRoles],'--') AS [UserInRoles], ---权限参数
		IsDelete,
		Cid,
		rootid
	From aspnet_Users WHERE IsLockout=0 AND UserName=@UserName --Where (@CompanyId=0 Or CompanyId=@CompanyId) And (@Stext IS NULL Or [Name] like '%'+@Stext+'%')
	)
	
	Select TOP 1 * From list
	RETURN
